function P=compute_constraint_distance_orthog_4param_9eq_10unk(m1,m2,m3,m4)

% Copyright (C) <2007>  <Francesc Moreno-Noguer, Vincent Lepetit, Pascal Fua>
% 
% This program is free software: you can redistribute it and/or modify
% it under the terms of the version 3 of the GNU General Public License
% as published by the Free Software Foundation.
% 
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
% General Public License for more details.       
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% Francesc Moreno-Noguer, CVLab-EPFL, September 2007.
% fmorenoguer@gmail.com, http://cvlab.epfl.ch/~fmoreno/ 

%redefine variables name, for compatibility with maple
m1_1=m1(1); 
m1_2=m1(2); 
m1_3=m1(3); 
m1_4=m1(4); 
m1_5=m1(5); 
m1_6=m1(6);
m1_7=m1(7); 
m1_8=m1(8); 
m1_9=m1(9); 
m1_10=m1(10); 
m1_11=m1(11); 
m1_12=m1(12);

m2_1=m2(1); 
m2_2=m2(2); 
m2_3=m2(3); 
m2_4=m2(4); 
m2_5=m2(5); 
m2_6=m2(6);
m2_7=m2(7); 
m2_8=m2(8); 
m2_9=m2(9); 
m2_10=m2(10); 
m2_11=m2(11); 
m2_12=m2(12);

m3_1=m3(1); 
m3_2=m3(2); 
m3_3=m3(3); 
m3_4=m3(4); 
m3_5=m3(5); 
m3_6=m3(6);
m3_7=m3(7); 
m3_8=m3(8); 
m3_9=m3(9); 
m3_10=m3(10); 
m3_11=m3(11); 
m3_12=m3(12);

m4_1=m4(1); 
m4_2=m4(2); 
m4_3=m4(3); 
m4_4=m4(4); 
m4_5=m4(5); 
m4_6=m4(6);
m4_7=m4(7); 
m4_8=m4(8); 
m4_9=m4(9); 
m4_10=m4(10); 
m4_11=m4(11); 
m4_12=m4(12);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

t1 = (m1_1 ^ 2);
t2 = (m1_2 ^ 2);
t3 = (m1_6 ^ 2);
t4 = (m1_3 ^ 2);
t5 = (m1_5 ^ 2);
t6 = (m1_4 * m1_1);
t8 = (m1_5 * m1_2);
t10 = (m1_6 * m1_3);
t12 = (m1_4 ^ 2);
t14 = (m2_5 * m1_2);
t15 = m1_3 * m2_3;
t16 = (m2_6 * m1_3);
t17 = m1_6 * m2_6;
t18 = m1_1 * m2_1;
t19 = (m1_4 * m2_1);
t20 = m1_2 * m2_2;
t21 = (m1_5 * m2_2);
t22 = m1_5 * m2_5;
t23 = (m1_6 * m2_3);
t24 = m1_4 * m2_4;
t25 = (m2_4 * m1_1);
t26 = (-t14 + t15 - t16 + t17 + t18 - t19 + t20 - t21 + t22 - t23 + t24 - t25);
t27 = (m1_5 * m3_2);
t28 = m1_3 * m3_3;
t29 = (m1_6 * m3_3);
t30 = m1_4 * m3_4;
t31 = (m3_4 * m1_1);
t32 = m1_1 * m3_1;
t33 = m1_5 * m3_5;
t34 = m1_6 * m3_6;
t35 = m1_2 * m3_2;
t36 = (m1_4 * m3_1);
t37 = (m3_6 * m1_3);
t38 = (m3_5 * m1_2);
t39 = (-t27 + t28 - t29 + t30 - t31 + t32 + t33 + t34 + t35 - t36 - t37 - t38);
t40 = m1_3 * m4_3;
t41 = (m1_4 * m4_1);
t42 = m1_2 * m4_2;
t43 = m1_6 * m4_6;
t44 = (m1_5 * m4_2);
t45 = (m4_6 * m1_3);
t46 = m1_1 * m4_1;
t47 = m1_5 * m4_5;
t48 = m1_4 * m4_4;
t49 = (m4_5 * m1_2);
t50 = (m4_4 * m1_1);
t51 = (m1_6 * m4_3);
t52 = (t40 - t41 + t42 + t43 - t44 - t45 + t46 + t47 + t48 - t49 - t50 - t51);
t53 = (m2_5 * m2_2);
t55 = (m2_6 * m2_3);
t57 = (m2_4 ^ 2);
t58 = (m2_1 ^ 2);
t59 = (m2_5 ^ 2);
t60 = (m2_2 ^ 2);
t61 = (m2_6 ^ 2);
t62 = (m2_3 ^ 2);
t63 = (m2_4 * m2_1);
t66 = m2_4 * m3_4;
t67 = m2_5 * m3_5;
t68 = (m3_6 * m2_3);
t69 = (m2_5 * m3_2);
t70 = m2_3 * m3_3;
t71 = m2_2 * m3_2;
t72 = m2_6 * m3_6;
t73 = (m2_6 * m3_3);
t74 = (m3_5 * m2_2);
t75 = (m2_4 * m3_1);
t76 = (m3_4 * m2_1);
t77 = m2_1 * m3_1;
t78 = (t66 + t67 - t68 - t69 + t70 + t71 + t72 - t73 - t74 - t75 - t76 + t77);
t79 = (m2_6 * m4_3);
t80 = (m4_6 * m2_3);
t81 = m2_3 * m4_3;
t82 = m2_6 * m4_6;
t83 = (m2_4 * m4_1);
t84 = (m4_4 * m2_1);
t85 = m2_1 * m4_1;
t86 = m2_4 * m4_4;
t87 = (m2_5 * m4_2);
t88 = (m4_5 * m2_2);
t89 = m2_2 * m4_2;
t90 = m2_5 * m4_5;
t91 = (-t79 - t80 + t81 + t82 - t83 - t84 + t85 + t86 - t87 - t88 + t89 + t90);
t92 = (m3_4 * m3_1);
t94 = (m3_4 ^ 2);
t95 = (m3_1 ^ 2);
t96 = (m3_5 ^ 2);
t97 = (m3_2 ^ 2);
t98 = (m3_6 ^ 2);
t99 = (m3_3 ^ 2);
t100 = (m3_5 * m3_2);
t102 = (m3_6 * m3_3);
t105 = m3_6 * m4_6;
t106 = (m3_5 * m4_2);
t107 = m3_3 * m4_3;
t108 = (m4_5 * m3_2);
t109 = m3_2 * m4_2;
t110 = (m4_4 * m3_1);
t111 = (m4_6 * m3_3);
t112 = m3_4 * m4_4;
t113 = m3_5 * m4_5;
t114 = (m3_4 * m4_1);
t115 = (m3_6 * m4_3);
t116 = m3_1 * m4_1;
t117 = (t105 - t106 + t107 - t108 + t109 - t110 - t111 + t112 + t113 - t114 - t115 + t116);
t118 = (m4_3 ^ 2);
t119 = (m4_4 ^ 2);
t120 = (m4_2 ^ 2);
t121 = (m4_5 * m4_2);
t123 = (m4_6 * m4_3);
t125 = (m4_1 ^ 2);
t126 = (m4_6 ^ 2);
t127 = (m4_5 ^ 2);
t128 = (m4_4 * m4_1);
t131 = (m1_7 ^ 2);
t132 = (m1_8 ^ 2);
t133 = (m1_9 ^ 2);
t134 = (m1_8 * m1_2);
t136 = (m1_9 * m1_3);
t138 = (m1_7 * m1_1);
t141 = m1_9 * m2_9;
t142 = (m2_8 * m1_2);
t143 = (m2_7 * m1_1);
t144 = (m1_8 * m2_2);
t145 = (m2_9 * m1_3);
t146 = m1_8 * m2_8;
t147 = (m1_7 * m2_1);
t148 = (m1_9 * m2_3);
t149 = m1_7 * m2_7;
t150 = (t141 + t20 - t142 + t15 - t143 - t144 - t145 + t146 - t147 - t148 + t18 + t149);
t151 = (m1_9 * m3_3);
t152 = (m1_7 * m3_1);
t153 = m1_7 * m3_7;
t154 = (m3_9 * m1_3);
t155 = m1_9 * m3_9;
t156 = (m1_8 * m3_2);
t157 = (m3_8 * m1_2);
t158 = (m3_7 * m1_1);
t159 = m1_8 * m3_8;
t160 = (t28 + t32 - t151 - t152 + t153 - t154 + t155 - t156 - t157 - t158 + t35 + t159);
t161 = (m4_8 * m1_2);
t162 = (m1_8 * m4_2);
t163 = m1_9 * m4_9;
t164 = (m1_9 * m4_3);
t165 = m1_8 * m4_8;
t166 = (m4_7 * m1_1);
t167 = (m4_9 * m1_3);
t168 = m1_7 * m4_7;
t169 = (m1_7 * m4_1);
t170 = (-t161 - t162 + t42 + t163 - t164 + t165 - t166 + t46 - t167 + t40 + t168 - t169);
t171 = (m2_9 * m2_3);
t173 = (m2_8 * m2_2);
t175 = (m2_8 ^ 2);
t176 = (m2_9 ^ 2);
t177 = (m2_7 * m2_1);
t179 = (m2_7 ^ 2);
t181 = m2_8 * m3_8;
t182 = m2_7 * m3_7;
t183 = (m2_7 * m3_1);
t184 = (m3_8 * m2_2);
t185 = (m2_8 * m3_2);
t186 = (m3_7 * m2_1);
t187 = (m3_9 * m2_3);
t188 = m2_9 * m3_9;
t189 = (m2_9 * m3_3);
t190 = (t77 + t71 + t181 + t70 + t182 - t183 - t184 - t185 - t186 - t187 + t188 - t189);
t191 = (m2_8 * m4_2);
t192 = m2_7 * m4_7;
t193 = (m2_7 * m4_1);
t194 = (m4_7 * m2_1);
t195 = (m2_9 * m4_3);
t196 = m2_8 * m4_8;
t197 = m2_9 * m4_9;
t198 = (m4_8 * m2_2);
t199 = (m4_9 * m2_3);
t200 = (-t191 + t192 - t193 + t89 - t194 - t195 + t196 + t197 - t198 + t85 + t81 - t199);
t201 = (m3_9 * m3_3);
t203 = (m3_7 * m3_1);
t205 = (m3_8 * m3_2);
t207 = (m3_7 ^ 2);
t208 = (m3_8 ^ 2);
t209 = (m3_9 ^ 2);
t211 = (m3_7 * m4_1);
t212 = (m4_9 * m3_3);
t213 = (m4_8 * m3_2);
t214 = (m4_7 * m3_1);
t215 = (m3_8 * m4_2);
t216 = m3_9 * m4_9;
t217 = (m3_9 * m4_3);
t218 = m3_7 * m4_7;
t219 = m3_8 * m4_8;
t220 = (-t211 + t109 - t212 - t213 - t214 - t215 + t216 - t217 + t107 + t218 + t219 + t116);
t221 = (m4_9 ^ 2);
t222 = (m4_7 ^ 2);
t223 = (m4_9 * m4_3);
t225 = (m4_8 ^ 2);
t226 = (m4_8 * m4_2);
t228 = (m4_7 * m4_1);
t231 = (m1_12 ^ 2);
t232 = (m1_11 * m1_2);
t234 = (m1_10 ^ 2);
t235 = (m1_11 ^ 2);
t236 = (m1_10 * m1_1);
t238 = (m1_12 * m1_3);
t241 = (m1_12 * m2_12);
t242 = (m1_12 * m2_3);
t243 = (m2_12 * m1_3);
t244 = (m1_10 * m2_1);
t245 = (m2_11 * m1_2);
t246 = (m1_11 * m2_11);
t247 = (m1_11 * m2_2);
t248 = (m2_10 * m1_1);
t249 = (m1_10 * m2_10);
t250 = (t241 - t242 - t243 - t244 + t18 - t245 + t246 - t247 + t20 + t15 - t248 + t249);
t251 = (m1_12 * m3_3);
t252 = (m1_12 * m3_12);
t253 = (m3_12 * m1_3);
t254 = (m1_10 * m3_1);
t255 = (m3_10 * m1_1);
t256 = (m1_10 * m3_10);
t257 = (m1_11 * m3_2);
t258 = (m3_11 * m1_2);
t259 = (m1_11 * m3_11);
t260 = (-t251 + t28 + t252 - t253 - t254 - t255 + t35 + t256 - t257 + t32 - t258 + t259);
t261 = (m4_11 * m1_2);
t262 = (m1_10 * m4_1);
t263 = (m1_10 * m4_10);
t264 = (m1_12 * m4_12);
t265 = (m1_12 * m4_3);
t266 = (m4_12 * m1_3);
t267 = (m1_11 * m4_2);
t268 = (m1_11 * m4_11);
t269 = (m4_10 * m1_1);
t270 = (-t261 + t46 - t262 + t263 + t42 + t264 + t40 - t265 - t266 - t267 + t268 - t269);
t271 = (m2_11 * m2_2);
t273 = (m2_12 * m2_3);
t275 = (m2_11 ^ 2);
t276 = (m2_12 ^ 2);
t277 = (m2_10 ^ 2);
t278 = (m2_10 * m2_1);
t281 = (m3_10 * m2_1);
t282 = (m3_12 * m2_3);
t283 = (m2_11 * m3_2);
t284 = (m2_11 * m3_11);
t285 = (m2_10 * m3_10);
t286 = (m2_10 * m3_1);
t287 = (m2_12 * m3_3);
t288 = (m2_12 * m3_12);
t289 = (m3_11 * m2_2);
t290 = (-t281 - t282 + t70 - t283 + t284 + t285 - t286 - t287 + t288 + t71 + t77 - t289);
t291 = (m2_11 * m4_2);
t292 = (m4_11 * m2_2);
t293 = (m4_10 * m2_1);
t294 = (m2_12 * m4_12);
t295 = (m2_12 * m4_3);
t296 = (m2_10 * m4_1);
t297 = (m2_10 * m4_10);
t298 = (m2_11 * m4_11);
t299 = (m4_12 * m2_3);
t300 = (-t291 - t292 - t293 + t294 + t89 - t295 + t81 + t85 - t296 + t297 + t298 - t299);
t301 = (m3_10 * m3_1);
t303 = (m3_12 ^ 2);
t304 = (m3_12 * m3_3);
t306 = (m3_11 * m3_2);
t308 = (m3_10 ^ 2);
t309 = (m3_11 ^ 2);
t311 = (m3_12 * m4_3);
t312 = (m3_10 * m4_10);
t313 = (m3_12 * m4_12);
t314 = (m3_11 * m4_2);
t315 = (m4_12 * m3_3);
t316 = (m4_11 * m3_2);
t317 = (m3_11 * m4_11);
t318 = (m3_10 * m4_1);
t319 = (m4_10 * m3_1);
t320 = (-t311 + t107 + t312 + t313 - t314 - t315 + t109 - t316 + t317 - t318 - t319 + t116);
t321 = (m4_11 ^ 2);
t322 = (m4_10 ^ 2);
t323 = (m4_11 * m4_2);
t325 = (m4_12 * m4_3);
t327 = (m4_10 * m4_1);
t329 = (m4_12 ^ 2);
t331 = (m1_8 * m1_5);
t333 = (m1_9 * m1_6);
t335 = (m1_7 * m1_4);
t338 = (m2_9 * m1_6);
t339 = (m1_7 * m2_4);
t340 = (m1_9 * m2_6);
t341 = (m2_7 * m1_4);
t342 = (m2_8 * m1_5);
t343 = (m1_8 * m2_5);
t344 = (t22 - t338 - t339 - t340 + t17 + t146 - t341 - t342 + t141 + t24 + t149 - t343);
t345 = (m3_9 * m1_6);
t346 = (m1_7 * m3_4);
t347 = (m1_9 * m3_6);
t348 = (m3_7 * m1_4);
t349 = (m3_8 * m1_5);
t350 = (m1_8 * m3_5);
t351 = (t153 - t345 - t346 + t155 + t30 - t347 - t348 + t33 - t349 + t159 + t34 - t350);
t352 = (m1_8 * m4_5);
t353 = (m4_8 * m1_5);
t354 = (m4_7 * m1_4);
t355 = (m1_9 * m4_6);
t356 = (m4_9 * m1_6);
t357 = (m1_7 * m4_4);
t358 = (-t352 + t48 + t165 - t353 - t354 + t163 + t43 + t168 + t47 - t355 - t356 - t357);
t359 = (m2_7 * m2_4);
t361 = (m2_9 * m2_6);
t363 = (m2_8 * m2_5);
t366 = (m2_7 * m3_4);
t367 = (m2_8 * m3_5);
t368 = (m3_7 * m2_4);
t369 = (m3_9 * m2_6);
t370 = (m2_9 * m3_6);
t371 = (m3_8 * m2_5);
t372 = (-t366 - t367 + t182 + t66 + t188 - t368 - t369 + t67 - t370 + t72 - t371 + t181);
t373 = (m2_8 * m4_5);
t374 = (m4_7 * m2_4);
t375 = (m2_7 * m4_4);
t376 = (m4_8 * m2_5);
t377 = (m2_9 * m4_6);
t378 = (m4_9 * m2_6);
t379 = (t196 + t82 - t373 + t90 - t374 + t86 + t192 + t197 - t375 - t376 - t377 - t378);
t380 = (m3_7 * m3_4);
t382 = (m3_8 * m3_5);
t384 = (m3_9 * m3_6);
t387 = (m4_9 * m3_6);
t388 = (m4_7 * m3_4);
t389 = (m3_9 * m4_6);
t390 = (m4_8 * m3_5);
t391 = (m3_8 * m4_5);
t392 = (m3_7 * m4_4);
t393 = (-t387 - t388 - t389 + t105 + t218 - t390 + t112 + t216 + t219 - t391 - t392 + t113);
t394 = (m4_9 * m4_6);
t396 = (m4_8 * m4_5);
t398 = (m4_7 * m4_4);
t401 = (m1_12 * m1_6);
t403 = (m1_10 * m1_4);
t405 = (m1_11 * m1_5);
t408 = (m2_11 * m1_5);
t409 = (m2_12 * m1_6);
t410 = (m1_10 * m2_4);
t411 = (m1_11 * m2_5);
t412 = (m2_10 * m1_4);
t413 = (m1_12 * m2_6);
t414 = (t246 + t22 + t241 - t408 + t249 - t409 + t24 - t410 - t411 - t412 + t17 - t413);
t415 = (m1_10 * m3_4);
t416 = (m3_12 * m1_6);
t417 = (m3_10 * m1_4);
t418 = (m1_12 * m3_6);
t419 = (m3_11 * m1_5);
t420 = (m1_11 * m3_5);
t421 = (-t415 + t33 + t252 - t416 - t417 - t418 + t30 + t34 + t259 + t256 - t419 - t420);
t422 = (m1_12 * m4_6);
t423 = (m1_11 * m4_5);
t424 = (m4_11 * m1_5);
t425 = (m4_10 * m1_4);
t426 = (m4_12 * m1_6);
t427 = (m1_10 * m4_4);
t428 = (t263 - t422 + t43 - t423 + t48 - t424 - t425 + t264 - t426 - t427 + t47 + t268);
t429 = (m2_12 * m2_6);
t431 = (m2_11 * m2_5);
t433 = (m2_10 * m2_4);
t436 = (m2_10 * m3_4);
t437 = (m3_11 * m2_5);
t438 = (m2_12 * m3_6);
t439 = (m3_10 * m2_4);
t440 = (m3_12 * m2_6);
t441 = (m2_11 * m3_5);
t442 = (t288 + t72 - t436 - t437 - t438 + t285 + t67 + t66 - t439 - t440 + t284 - t441);
t443 = (m4_11 * m2_5);
t444 = (m2_12 * m4_6);
t445 = (m4_12 * m2_6);
t446 = (m2_11 * m4_5);
t447 = (m2_10 * m4_4);
t448 = (m4_10 * m2_4);
t449 = (t298 + t294 + t297 + t90 - t443 - t444 + t86 - t445 - t446 - t447 + t82 - t448);
t450 = (m3_10 * m3_4);
t452 = (m3_12 * m3_6);
t454 = (m3_11 * m3_5);
t457 = (m3_12 * m4_6);
t458 = (m3_11 * m4_5);
t459 = (m4_12 * m3_6);
t460 = (m3_10 * m4_4);
t461 = (m4_10 * m3_4);
t462 = (m4_11 * m3_5);
t463 = (-t457 - t458 + t313 - t459 + t105 + t312 - t460 + t317 - t461 + t113 - t462 + t112);
t464 = (m4_12 * m4_6);
t466 = (m4_10 * m4_4);
t468 = (m4_11 * m4_5);
t471 = (m1_12 * m1_9);
t473 = (m1_10 * m1_7);
t475 = (m1_11 * m1_8);
t478 = (m2_12 * m1_9);
t479 = (m2_11 * m1_8);
t480 = (m1_10 * m2_7);
t481 = (m1_12 * m2_9);
t482 = (m2_10 * m1_7);
t483 = (m1_11 * m2_8);
t484 = (t149 - t478 - t479 - t480 - t481 - t482 + t246 + t249 + t241 + t141 + t146 - t483);
t485 = (m1_11 * m3_8);
t486 = (m3_12 * m1_9);
t487 = (m3_11 * m1_8);
t488 = (m1_12 * m3_9);
t489 = (m1_10 * m3_7);
t490 = (m3_10 * m1_7);
t491 = (t159 + t256 - t485 + t252 - t486 - t487 - t488 + t155 - t489 - t490 + t259 + t153);
t492 = (m1_11 * m4_8);
t493 = (m4_10 * m1_7);
t494 = (m4_11 * m1_8);
t495 = (m1_10 * m4_7);
t496 = (m4_12 * m1_9);
t497 = (m1_12 * m4_9);
t498 = (-t492 + t165 + t163 - t493 - t494 - t495 + t168 + t263 + t264 + t268 - t496 - t497);
t499 = (m2_12 * m2_9);
t501 = (m2_11 * m2_8);
t503 = (m2_10 * m2_7);
t506 = (m2_10 * m3_7);
t507 = (m3_10 * m2_7);
t508 = (m3_12 * m2_9);
t509 = (m3_11 * m2_8);
t510 = (m2_11 * m3_8);
t511 = (m2_12 * m3_9);
t512 = (t288 - t506 - t507 - t508 + t285 + t182 - t509 - t510 + t181 - t511 + t188 + t284);
t513 = (m2_11 * m4_8);
t514 = (m4_11 * m2_8);
t515 = (m2_12 * m4_9);
t516 = (m4_10 * m2_7);
t517 = (m4_12 * m2_9);
t518 = (m2_10 * m4_7);
t519 = (-t513 - t514 - t515 - t516 + t196 + t192 + t297 + t294 - t517 - t518 + t197 + t298);
t520 = (m3_10 * m3_7);
t522 = (m3_11 * m3_8);
t524 = (m3_12 * m3_9);
t527 = (m3_12 * m4_9);
t528 = (m4_12 * m3_9);
t529 = (m3_11 * m4_8);
t530 = (m4_10 * m3_7);
t531 = (m4_11 * m3_8);
t532 = (m3_10 * m4_7);
t533 = (-t527 - t528 + t313 + t218 - t529 + t216 + t317 + t312 - t530 + t219 - t531 - t532);
t534 = (m4_11 * m4_8);
t536 = (m4_12 * m4_9);
t538 = (m4_10 * m4_7);
t541 = (-t232 - t236 - t401 + t6 + t8 + t10 - t405 - t403 + t234 + t235 - t238 + t231);
t543 = 2 * t241;
t544 = 2 * t249;
t545 = 2 * t246;
t546 = t543 - t408 - t242 + t544 - t244 + t16 - t411 + t25 + t545 - t247 + t19;
t548 = 2 * t252;
t550 = 2 * t259;
t551 = 2 * t256;
t552 = -t420 - t419 + t550 + t29 + t36 - t251 - t255 + t38 + t31 + t551 - t415;
t555 = 2 * t268;
t556 = 2 * t263;
t557 = 2 * t264;
t558 = t41 + t51 + t555 - t261 - t423 - t265 + t556 - t426 - t427 - t269 + t557;
t560 = (-t278 - t433 - t429 + t63 + t53 + t55 + t275 + t276 - t273 - t271 + t277 - t431);
t561 = 2 * t288;
t562 = 2 * t284;
t564 = 2 * t285;
t565 = t75 + t76 - t436 - t281 - t440 + t74 - t289 - t441 + t68 - t283 + t564;
t567 = 2 * t297;
t568 = 2 * t298;
t570 = 2 * t294;
t571 = t79 - t296 - t448 - t446 - t293 + t80 + t84 + t570 - t291 + t83 - t445;
t573 = (t303 - t304 - t301 - t450 - t452 - t306 - t454 + t308 + t309 + t92 + t100 + t102);
t574 = 2 * t312;
t575 = 2 * t317;
t577 = 2 * t313;
t578 = -t311 + t577 - t461 - t462 + t111 + t114 + t115 - t318 + t106 - t319 - t457;
t580 = (t329 + t121 + t128 - t325 - t327 - t323 - t468 + t123 + t321 - t466 - t464 + t322);
t581 = (-t475 - t471 - t232 + t234 + t235 + t134 + t136 + t138 - t236 - t238 - t473 + t231);
t583 = -t248 + t143 - t479 - t483 + t144 - t482 + t543 - t242 + t545 - t247 - t244;
t586 = t548 + t152 + t151 - t488 - t489 + t551 + t158 + t156 - t490 - t253 + t154;
t589 = -t497 + t164 + t167 + t169 + t166 + t557 + t556 + t161 + t555 - t496 - t269;
t591 = (t276 + t277 + t177 - t503 + t171 - t499 - t278 + t173 + t275 - t273 - t271 - t501);
t593 = -t282 + t184 + t185 - t509 - t506 - t281 - t510 + t189 - t511 + t186 - t289;
t596 = -t515 + t567 - t518 + t568 - t513 + t194 - t293 + t191 - t517 - t292 + t199;
t598 = (-t306 + t303 - t301 - t522 - t524 - t520 + t203 - t304 + t201 + t308 + t309 + t205);
t600 = -t319 + t213 + t574 + t215 + t212 - t314 + t575 + t217 - t532 - t530 - t531;
t602 = (-t327 + t321 + t329 + t226 + t322 - t325 - t536 + t228 - t538 + t223 - t534 - t323);
t603 = (-t475 - t473 - t405 + t231 + t235 + t335 - t401 - t471 + t234 - t403 + t331 + t333);
t605 = t339 - t413 - t479 - t409 + t544 - t411 - t412 + t342 - t483 - t410 + t341;
t608 = -t417 + t551 - t489 + t348 + t350 - t486 + t349 + t550 + t347 - t416 - t415;
t611 = t556 + t557 - t497 - t492 - t427 - t496 + t555 - t426 + t355 + t356 + t357;
t613 = (t359 - t429 - t499 + t276 - t433 - t501 + t363 + t275 - t503 + t361 - t431 + t277);
t615 = t369 - t507 - t509 - t440 - t506 + t371 - t510 + t562 - t511 - t439 - t441;
t618 = -t444 - t514 + t378 + t570 + t377 - t447 + t374 + t376 - t517 + t373 - t515;
t620 = (-t522 + t384 - t524 + t303 - t450 - t452 - t520 - t454 + t308 + t309 + t380 + t382);
t622 = t575 + t389 + t390 - t461 - t462 - t529 - t532 - t530 + t391 - t531 + t392;
t624 = (t396 - t466 - t534 + t394 + t321 + t329 - t464 + t322 - t536 - t538 + t398 - t468);
P(1,1) = t1 + t2 + t3 + t4 + t5 - 2 * t6 - 2 * t8 - 2 * t10 + t12;
P(1,2) = 2 * t26;
P(1,3) = 2 * t39;
P(1,4) = 2 * t52;
P(1,5) = -2 * t53 - 2 * t55 + t57 + t58 + t59 + t60 + t61 + t62 - 2 * t63;
P(1,6) = 2 * t78;
P(1,7) = 2 * t91;
P(1,8) = -2 * t92 + t94 + t95 + t96 + t97 + t98 + t99 - 2 * t100 - 2 * t102;
P(1,9) = 2 * t117;
P(1,10) = t118 + t119 + t120 - 2 * t121 - 2 * t123 + t125 + t126 + t127 - 2 * t128;
P(2,1) = t1 + t4 + t131 + t132 + t133 - 2 * t134 - 2 * t136 - 2 * t138 + t2;
P(2,2) = 2 * t150;
P(2,3) = 2 * t160;
P(2,4) = 2 * t170;
P(2,5) = -2 * t171 - 2 * t173 + t60 + t62 + t58 + t175 + t176 - 2 * t177 + t179;
P(2,6) = 2 * t190;
P(2,7) = 2 * t200;
P(2,8) = -2 * t201 - 2 * t203 - 2 * t205 + t207 + t208 + t209 + t95 + t97 + t99;
P(2,9) = 2 * t220;
P(2,10) = t221 + t120 + t222 - 2 * t223 + t225 + t118 - 2 * t226 + t125 - 2 * t228;
P(3,1) = t231 - 2 * t232 + t2 + t234 + t235 + t1 - 2 * t236 - 2 * t238 + t4;
P(3,2) = 2 * t250;
P(3,3) = 2 * t260;
P(3,4) = 2 * t270;
P(3,5) = -2 * t271 - 2 * t273 + t275 + t276 + t277 + t58 + t60 + t62 - 2 * t278;
P(3,6) = 2 * t290;
P(3,7) = 2 * t300;
P(3,8) = -2 * t301 + t303 - 2 * t304 - 2 * t306 + t308 + t309 + t95 + t97 + t99;
P(3,9) = 2 * t320;
P(3,10) = t118 + t321 + t322 - 2 * t323 - 2 * t325 - 2 * t327 + t120 + t329 + t125;
P(4,1) = t3 - 2 * t331 - 2 * t333 - 2 * t335 + t132 + t133 + t131 + t12 + t5;
P(4,2) = 2 * t344;
P(4,3) = 2 * t351;
P(4,4) = 2 * t358;
P(4,5) = -2 * t359 + t59 - 2 * t361 - 2 * t363 + t57 + t176 + t61 + t179 + t175;
P(4,6) = 2 * t372;
P(4,7) = 2 * t379;
P(4,8) = t209 - 2 * t380 - 2 * t382 - 2 * t384 + t208 + t94 + t96 + t98 + t207;
P(4,9) = 2 * t393;
P(4,10) = t126 + t225 + t127 - 2 * t394 - 2 * t396 - 2 * t398 + t119 + t222 + t221;
P(5,1) = -2 * t401 + t12 + t3 - 2 * t403 + t231 + t5 - 2 * t405 + t234 + t235;
P(5,2) = 2 * t414;
P(5,3) = 2 * t421;
P(5,4) = 2 * t428;
P(5,5) = -2 * t429 + t276 + t57 + t277 + t61 + t275 + t59 - 2 * t431 - 2 * t433;
P(5,6) = 2 * t442;
P(5,7) = 2 * t449;
P(5,8) = t303 - 2 * t450 - 2 * t452 - 2 * t454 + t308 + t309 + t94 + t96 + t98;
P(5,9) = 2 * t463;
P(5,10) = t126 + t119 + t321 + t329 - 2 * t464 - 2 * t466 - 2 * t468 + t322 + t127;
P(6,1) = t132 + t133 + t131 - 2 * t471 + t231 - 2 * t473 - 2 * t475 + t234 + t235;
P(6,2) = 2 * t484;
P(6,3) = 2 * t491;
P(6,4) = 2 * t498;
P(6,5) = -2 * t499 + t175 + t275 + t179 - 2 * t501 + t276 + t176 - 2 * t503 + t277;
P(6,6) = 2 * t512;
P(6,7) = 2 * t519;
P(6,8) = t303 + t207 - 2 * t520 - 2 * t522 - 2 * t524 + t308 + t309 + t208 + t209;
P(6,9) = 2 * t533;
P(6,10) = t329 - 2 * t534 + t321 + t222 + t221 + t225 + t322 - 2 * t536 - 2 * t538;
P(7,1) = t541;
P(7,2) = -t248 + t21 - t410 + t14 - t243 - t412 - t245 - t409 - t413 + t23 + t546;
P(7,3) = -t417 - t258 - t253 - t257 - t254 + t548 - t418 - t416 + t37 + t27 + t552;
P(7,4) = -t425 - t422 + t44 + t50 + t45 - t424 - t266 - t267 - t262 + t49 + t558;
P(7,5) = t560;
P(7,6) = -t286 - t287 - t437 + t73 - t439 + t561 + t562 - t282 - t438 + t69 + t565;
P(7,7) = -t295 + t567 - t447 + t568 + t87 + t88 - t443 - t444 - t299 - t292 + t571;
P(7,8) = t573;
P(7,9) = -t459 - t316 - t315 - t314 - t458 + t574 + t108 - t460 + t110 + t575 + t578;
P(7,10) = t580;
P(8,1) = t581;
P(8,2) = -t478 - t481 - t480 - t243 + t148 + t145 + t544 + t147 + t142 - t245 + t583;
P(8,3) = t157 - t485 - t251 + t550 - t486 - t487 - t258 - t257 - t255 - t254 + t586;
P(8,4) = -t261 - t495 - t262 + t162 - t492 - t265 - t266 - t494 - t267 - t493 + t589;
P(8,5) = t591;
P(8,6) = t561 - t286 + t187 + t564 - t283 - t507 + t562 - t508 - t287 + t183 + t593;
P(8,7) = -t516 - t296 + t198 - t291 + t570 - t295 + t195 - t299 + t193 - t514 + t596;
P(8,8) = t598;
P(8,9) = -t528 - t316 - t527 - t318 + t577 - t315 + t214 - t529 - t311 + t211 + t600;
P(8,10) = t602;
P(9,1) = t603;
P(9,2) = t338 - t408 - t480 - t482 + t340 - t478 + t545 + t343 + t543 - t481 + t605;
P(9,3) = -t418 + t346 - t419 + t548 + t345 - t488 - t420 - t487 - t485 - t490 + t608;
P(9,4) = -t425 + t354 - t493 - t424 - t422 + t352 - t423 - t494 + t353 - t495 + t611;
P(9,5) = t613;
P(9,6) = t368 + t366 + t564 + t370 + t561 - t508 - t436 - t438 - t437 + t367 + t615;
P(9,7) = -t516 + t375 - t445 - t448 + t568 - t443 - t513 - t518 + t567 - t446 + t618;
P(9,8) = t620;
P(9,9) = t577 + t387 - t458 - t459 - t460 + t574 - t528 - t527 + t388 - t457 + t622;
P(9,10) = t624;